<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <template id="sub-component">
        <div>
            <h2>我是子组件标题</h2>
            <slot></slot>
        </div>
    </template>

    <main id="app">
        <h2>引入子组件</h2>
        <!-- 子组件的内容中定义的“东西”，会在<slot>插槽出口中展示出来 -->
        <sub-component>
            <!-- 父组件中的name -->
            <p>我的名字：{{name}}</p>
        </sub-component>
        <sub-component>
            <!-- 父组件中的name -->
            <div>我的年龄：{{age}}</div>
        </sub-component>
    </main>
</body>
<script src="../vue.js"></script>
<script>

    Vue.component("sub-component", {
        template: "#sub-component",
        data() {
            return {

            }
        }
    })

    new Vue({
        el: "#app",
        data() {
            return {
                name: "奉先",
                age: 35
            }
        }
    })
</script>

</html>